using System;
using System.Collections.Generic;
using Headsight.BPMN2WF.BPMN.Model;
using Headsight.BPMN2WF.BPMN.Schemas;

namespace Headsight.BPMN2WF.Testing.TestObjCtors
{
    /// <summary>
    /// <see cref="BPMNFlowNode"/> <see cref="ITestObjCtor{T}"/>.
    /// </summary>
    public class BPMNFlowNodeCtor : ITestObjCtor<BPMNFlowNode>
    {
        private String _id;
        private int _numOfSeqFlowsIn;
        private readonly IList<string> _bpmnSequenceFlowsTargetRefs;
        private tFlowElement _tFlowElement;

        public BPMNFlowNodeCtor()
        {
            _bpmnSequenceFlowsTargetRefs = new List<String>();
        }

        public BPMNFlowNode Create()
        {
            return new BPMNFlowNode
                (
                    (tFlowNode) (_tFlowElement ?? new tFlowNodeCtor().WithId(_id ?? Guid.NewGuid().ToString("B")).Create()), 
                    new List<BPMNArgument>(), 
                    new List<BPMNArgument>()
                );
        }

        public BPMNFlowNodeCtor WithId(String id)
        {
            _id = id;

            return this;
        }

        public BPMNFlowNodeCtor WithNumBPMNSequenceFlowsIn(int numberOfSequenceFlowsIn)
        {
            _numOfSeqFlowsIn = numberOfSequenceFlowsIn;

            return this;
        }

        public BPMNFlowNodeCtor WithNumBPMNSequenceFlowsOutTo(String bpmnFlowNodeIn)
        {
            _bpmnSequenceFlowsTargetRefs.Add(bpmnFlowNodeIn);

            return this;
        }

        public BPMNFlowNodeCtor WithTFlowElement(tFlowElement tFlowElement)
        {
            _tFlowElement = tFlowElement;

            return this;
        }
    }
}